package cn.wxq.daily.empdailymgforserve.service.impl;

import cn.wxq.daily.empdailymgforserve.domain.Vacation;
import cn.wxq.daily.empdailymgforserve.mapper.VacationDao;
import cn.wxq.daily.empdailymgforserve.service.VacationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 出勤休假业务层
 */
@Service
public class VacationServiceImpl implements VacationService {
    @Autowired
    private VacationDao vacationDao;

    @Override
    public List<Vacation> findByPage(Vacation vacation) {
        return vacationDao.findByPage(vacation);
    }

    /**
     * 新增
     * @param vacation
     * @return
     */
    @Override
    public int insertVacation(Vacation vacation) {
        vacation.setAddTime(new Date());
        vacation.setStatus("2");
        return vacationDao.insertVacation(vacation);
    }

    @Override
    public int updateVacation(Vacation vacation) {

        return vacationDao.updateVacation(vacation);
    }

    @Override
    public int deleteById(Integer leaveId) {
        return vacationDao.deleteById(leaveId);
    }

    @Override
    public Vacation selectVacationById(Integer leaveId) {
        return vacationDao.selectVacationById(leaveId);
    }

    @Override
    public List<Vacation> findALL() {
        return vacationDao.findALL();
    }

    /**
     * 通过用户名字查询
     * @param nickName
     * @return
     */
    @Override
    public List<Vacation> selectVacationByUserName(String nickName) {
        return vacationDao.selectVacationByUserName(nickName);
    }
}
